define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'mall.banner/index',
        add_url: 'mall.banner/add',
        edit_url: 'mall.banner/edit',
        delete_url: 'mall.banner/delete',
        export_url: 'mall.banner/export',
        modify_url: 'mall.banner/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: 'id', search: false},
                    {field: 'title', title: '标题', searchOp: '%*%'},
                    {field: 'image', title: 'banner图片', templet: ea.table.image, search: false},
                    {field: 'sort', title: '排序', edit: 'text', search: false},
                    {
                        field: 'status',
                        search: 'select',
                        selectList: ["禁用", "启用"],
                        auth: 'modify',
                        title: '状态',
                        templet: ea.table.switch
                    },
                    // {field: 'goods.title', title: '链接产品', search: false},
                    {field: 'remark', title: '备注说明', templet: ea.table.text, search: false},

                    {field: 'create_time', title: '创建时间', search: 'false'},
                    {
                        field: 'create_time_left',
                        minWidth: 80,
                        title: '创建开始时间',
                        search: 'rangeLeft',
                        hide: true,
                        searchOp: 'rangeLeft'
                    },
                    {
                        field: 'create_time_right',
                        minWidth: 80,
                        title: '创建结束时间',
                        search: 'rangeRight',
                        hide: true,
                        searchOp: 'rangeRight'
                    },
                    {width: 250, title: '操作', templet: ea.table.tool},
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },


    };
    var form = layui.form
    form.on('select(type)', function (data) {
        console.log(data.value)
        if (data.value == 1) {
            $('#product').show()
            $('#article').hide()
        } else if (data.value == 2) {
            $('#product').hide()
            $('#article').show()
        }

    });
    return Controller;
});